library(ggplot2) 
library(sf)
library(tidyr)
map_2018 <- st_read("liveuamap_2018-01-01.kml")


cbp2 <- c("rosybrown2", "gray86", "gray92","gray70", 
          "gray78","palegreen2","gray96")
syria_2018 <- ggplot(st_zm(map_2018)) + 
  geom_sf(aes(fill=Name)) + ggtitle("Dec 1, 2017 - Jan 1, 2018") +
  scale_fill_manual(name="Controlled by", values = cbp2,
                    labels = c("Government", "Golan Heights", "HTS","ISIS","SDF","Opposition","Turkey")) +  
  theme_classic() +theme(axis.line=element_blank(),axis.text.x=element_blank(),
                         axis.text.y=element_blank(),axis.ticks=element_blank(),
                         axis.title.x=element_blank(),
                         axis.title.y=element_blank(),
                         plot.title = element_text(hjust = 0.5, size = 14, family = "LM Roman 10"),
                         legend.text=element_text(size=12, family = "LM Roman 10"),
                         legend.title=element_text(size=12, family = "LM Roman 10"))

syria_2018
 
ged <- read.csv("ged_main_2024.csv") 
mydf <- ged[which(ged$dyad_new_id==11973 & ged$date_end>"2017-12-01" & ged$date_end<"2018-01-01"),]
mydf1 <- mydf[which(mydf$control1=="Asad"),]
mydf1 <- data.frame("Assad Forces"=mydf1$deaths_a, "Civilians"=mydf1$deaths_civilians,
                    "lat"=mydf1$latitude, "long"=mydf1$longitude, "control"=mydf1$control1)
mydf2 <- mydf[which(mydf$control1=="Opposition"),]
mydf2 <- data.frame("Opposition Forces"=mydf2$deaths_b, "Civilians"=mydf2$deaths_civilians,
                    "lat"=mydf2$latitude, "long"=mydf2$longitude, "control"=mydf2$control1)


df1_long <- mydf1 %>% gather(death, value, -c(lat, long, control))
df2_long <- mydf2 %>% gather(death, value, -c(lat, long, control))
df_long <- rbind(df1_long,df2_long)

### MAP in Appendix

syria_2018 <- syria_2018 + geom_point(data = df_long, aes(x = long, y = lat, color=death, size=value), position=position_jitter(h=0.15,w=0.15)) +
  scale_color_manual(name="Deaths from", values = c("Assad.Forces"="red","Opposition.Forces"="darkorchid4","Civilians"="black"))
syria_2018

ggsave("syria_2018.pdf", plot = syria_2018, 
       device = cairo_pdf,width=8.2, height=5,units = "in")  